<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /fasttmp/mkdist-qt-4.3.5-1211793125/qtopia-core-opensource-src-4.3.5/doc/src/qpair.qdoc -->
<head>
  <title>Qt 4.3: QPair Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QPair Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1>
<p>The QPair class is a template class that stores a pair of items. <a href="#details">More...</a></p>
<pre> #include &lt;QPair&gt;</pre><ul>
<li><a href="qpair-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h3>Public Types</h3>
<ul>
<li><div class="fn"/>typedef <b><a href="qpair.html#first_type-typedef">first_type</a></b></li>
<li><div class="fn"/>typedef <b><a href="qpair.html#second_type-typedef">second_type</a></b></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qpair.html#QPair">QPair</a></b> ()</li>
<li><div class="fn"/><b><a href="qpair.html#QPair-2">QPair</a></b> ( const T1 &amp; <i>value1</i>, const T2 &amp; <i>value2</i> )</li>
<li><div class="fn"/>QPair&lt;T1, T2&gt; &amp; <b><a href="qpair.html#operator-eq">operator=</a></b> ( const QPair&lt;T1, T2&gt; &amp; <i>other</i> )</li>
</ul>
<a name="public-variables"></a>
<h3>Public Variables</h3>
<ul>
<li><div class="fn"/>T1 <b><a href="qpair.html#first-var">first</a></b></li>
<li><div class="fn"/>T2 <b><a href="qpair.html#second-var">second</a></b></li>
</ul>
<a name="related-non-members"></a>
<h3>Related Non-Members</h3>
<ul>
<li><div class="fn"/>QPair&lt;T1, T2&gt; <b><a href="qpair.html#qMakePair">qMakePair</a></b> ( const T1 &amp; <i>value1</i>, const T2 &amp; <i>value2</i> )</li>
<li><div class="fn"/>bool <b><a href="qpair.html#operator-not-eq-12">operator!=</a></b> ( const QPair&lt;T1, T2&gt; &amp; <i>p1</i>, const QPair&lt;T1, T2&gt; &amp; <i>p2</i> )</li>
<li><div class="fn"/>bool <b><a href="qpair.html#operator-lt-5">operator&lt;</a></b> ( const QPair&lt;T1, T2&gt; &amp; <i>p1</i>, const QPair&lt;T1, T2&gt; &amp; <i>p2</i> )</li>
<li><div class="fn"/>QDataStream &amp; <b><a href="qpair.html#operator-lt-lt-42">operator&lt;&lt;</a></b> ( QDataStream &amp; <i>out</i>, const QPair&lt;T1, T2&gt; &amp; <i>pair</i> )</li>
<li><div class="fn"/>bool <b><a href="qpair.html#operator-lt-eq-2">operator&lt;=</a></b> ( const QPair&lt;T1, T2&gt; &amp; <i>p1</i>, const QPair&lt;T1, T2&gt; &amp; <i>p2</i> )</li>
<li><div class="fn"/>bool <b><a href="qpair.html#operator-eq-eq-21">operator==</a></b> ( const QPair&lt;T1, T2&gt; &amp; <i>p1</i>, const QPair&lt;T1, T2&gt; &amp; <i>p2</i> )</li>
<li><div class="fn"/>bool <b><a href="qpair.html#operator-gt-2">operator&gt;</a></b> ( const QPair&lt;T1, T2&gt; &amp; <i>p1</i>, const QPair&lt;T1, T2&gt; &amp; <i>p2</i> )</li>
<li><div class="fn"/>bool <b><a href="qpair.html#operator-gt-eq-2">operator&gt;=</a></b> ( const QPair&lt;T1, T2&gt; &amp; <i>p1</i>, const QPair&lt;T1, T2&gt; &amp; <i>p2</i> )</li>
<li><div class="fn"/>QDataStream &amp; <b><a href="qpair.html#operator-gt-gt-25">operator&gt;&gt;</a></b> ( QDataStream &amp; <i>in</i>, QPair&lt;T1, T2&gt; &amp; <i>pair</i> )</li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QPair class is a template class that stores a pair of items.</p>
<p>QPair&lt;T1, T2&gt; can be used in your application if the STL <tt>pair</tt> type is not available. It stores one value of type T1 and one value of type T2. It can be used as a return value for a function that needs to return two values, or as the value type of a <a href="containers.html">generic container</a>.</p>
<p>Here's an example of a QPair that stores one <a href="qstring.html">QString</a> and one <tt>double</tt> value:</p>
<pre> QPair&lt;QString, double&gt; pair;</pre>
<p>The components are accessible as public data members called <a href="qpair.html#first-var">first</a> and <a href="qpair.html#second-var">second</a>. For example:</p>
<pre> pair.first = &quot;pi&quot;;
 pair.second = 3.14159265358979323846;</pre>
<p>QPair's template data types (T1 and T2) must be <a href="containers.html#assignable-data-types">assignable data types</a>. You cannot, for example, store a <a href="qwidget.html">QWidget</a> as a value; instead, store a <a href="qwidget.html">QWidget</a> *. A few functions have additional requirements; these requirements are documented on a per-function basis.</p>
<p>See also <a href="containers.html">Generic Containers</a>.</p>
<hr />
<h2>Member Type Documentation</h2>
<h3 class="fn"><a name="first_type-typedef"></a>typedef QPair::first_type</h3>
<p>The type of the first element in the pair (T1).</p>
<p>See also <a href="qpair.html#first-var">first</a>.</p>
<h3 class="fn"><a name="second_type-typedef"></a>typedef QPair::second_type</h3>
<p>The type of the second element in the pair (T2).</p>
<p>See also <a href="qpair.html#second-var">second</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QPair"></a>QPair::QPair ()</h3>
<p>Constructs an empty pair. The <tt>first</tt> and <tt>second</tt> elements are initialized with <a href="containers.html#default-constructed-values">default-constructed values</a>.</p>
<h3 class="fn"><a name="QPair-2"></a>QPair::QPair ( const T1 &amp; <i>value1</i>, const T2 &amp; <i>value2</i> )</h3>
<p>Constructs a pair and initializes the <tt>first</tt> element with <i>value1</i> and the <tt>second</tt> element with <i>value2</i>.</p>
<p>See also <a href="qpair.html#qMakePair">qMakePair</a>().</p>
<h3 class="fn"><a name="operator-eq"></a>QPair&lt;T1, T2&gt; &amp; QPair::operator= ( const QPair&lt;T1, T2&gt; &amp; <i>other</i> )</h3>
<p>Assigns <i>other</i> to this pair.</p>
<hr />
<h2>Member Variable Documentation</h2>
<h3 class="fn"><a name="first-var"></a>T1 QPair::first</h3>
<p>The first element in the pair.</p>
<h3 class="fn"><a name="second-var"></a>T2 QPair::second</h3>
<p>The second element in the pair.</p>
<hr />
<h2>Related Non-Members</h2>
<h3 class="fn"><a name="qMakePair"></a>QPair&lt;T1, T2&gt; qMakePair ( const T1 &amp; <i>value1</i>, const T2 &amp; <i>value2</i> )</h3>
<p>Returns a <a href="qpair.html">QPair</a>&lt;T1, T2&gt; that contains <i>value1</i> and <i>value2</i>. Example:</p>
<pre> QList&lt;QPair&lt;int, double&gt; &gt; list;
 list.append(qMakePair(66, 3.14159));</pre>
<p>This is equivalent to <a href="qpair.html">QPair</a>&lt;T1, T2&gt;(<i>value1</i>, <i>value2</i>), but usually requires less typing.</p>
<h3 class="fn"><a name="operator-not-eq-12"></a>bool operator!= ( const QPair&lt;T1, T2&gt; &amp; <i>p1</i>, const QPair&lt;T1, T2&gt; &amp; <i>p2</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Returns true if <i>p1</i> is not equal to <i>p2</i>; otherwise returns false. Two pairs compare as not equal if their <tt>first</tt> data members are not equal or if their <tt>second</tt> data members are not equal.</p>
<p>This function requires the T1 and T2 types to have an implementation of <tt>operator==()</tt>.</p>
<h3 class="fn"><a name="operator-lt-5"></a>bool operator&lt; ( const QPair&lt;T1, T2&gt; &amp; <i>p1</i>, const QPair&lt;T1, T2&gt; &amp; <i>p2</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Returns true if <i>p1</i> is less than <i>p2</i>; otherwise returns false. The comparison is done on the <tt>first</tt> members of <i>p1</i> and <i>p2</i>; if they compare equal, the <tt>second</tt> members are compared to break the tie.</p>
<p>This function requires the T1 and T2 types to have an implementation of <tt>operator&lt;()</tt>.</p>
<h3 class="fn"><a name="operator-lt-lt-42"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>out</i>, const QPair&lt;T1, T2&gt; &amp; <i>pair</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Writes the pair <i>pair</i> to stream <i>out</i>.</p>
<p>This function requires the T1 and T2 types to implement <tt>operator&lt;&lt;()</tt>.</p>
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
<h3 class="fn"><a name="operator-lt-eq-2"></a>bool operator&lt;= ( const QPair&lt;T1, T2&gt; &amp; <i>p1</i>, const QPair&lt;T1, T2&gt; &amp; <i>p2</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Returns true if <i>p1</i> is less than or equal to <i>p2</i>; otherwise returns false. The comparison is done on the <tt>first</tt> members of <i>p1</i> and <i>p2</i>; if they compare equal, the <tt>second</tt> members are compared to break the tie.</p>
<p>This function requires the T1 and T2 types to have an implementation of <tt>operator&lt;()</tt>.</p>
<h3 class="fn"><a name="operator-eq-eq-21"></a>bool operator== ( const QPair&lt;T1, T2&gt; &amp; <i>p1</i>, const QPair&lt;T1, T2&gt; &amp; <i>p2</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Returns true if <i>p1</i> is equal to <i>p2</i>; otherwise returns false. Two pairs compare equal if their <tt>first</tt> data members compare equal and if their <tt>second</tt> data members compare equal.</p>
<p>This function requires the T1 and T2 types to have an implementation of <tt>operator==()</tt>.</p>
<h3 class="fn"><a name="operator-gt-2"></a>bool operator&gt; ( const QPair&lt;T1, T2&gt; &amp; <i>p1</i>, const QPair&lt;T1, T2&gt; &amp; <i>p2</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Returns true if <i>p1</i> is greater than <i>p2</i>; otherwise returns false. The comparison is done on the <tt>first</tt> members of <i>p1</i> and <i>p2</i>; if they compare equal, the <tt>second</tt> members are compared to break the tie.</p>
<p>This function requires the T1 and T2 types to have an implementation of <tt>operator&lt;()</tt>.</p>
<h3 class="fn"><a name="operator-gt-eq-2"></a>bool operator&gt;= ( const QPair&lt;T1, T2&gt; &amp; <i>p1</i>, const QPair&lt;T1, T2&gt; &amp; <i>p2</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Returns true if <i>p1</i> is greater than or equal to <i>p2</i>; otherwise returns false. The comparison is done on the <tt>first</tt> members of <i>p1</i> and <i>p2</i>; if they compare equal, the <tt>second</tt> members are compared to break the tie.</p>
<p>This function requires the T1 and T2 types to have an implementation of <tt>operator&lt;()</tt>.</p>
<h3 class="fn"><a name="operator-gt-gt-25"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>in</i>, QPair&lt;T1, T2&gt; &amp; <i>pair</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Reads a pair from stream <i>in</i> into <i>pair</i>.</p>
<p>This function requires the T1 and T2 types to implement <tt>operator&gt;&gt;()</tt>.</p>
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2008 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.3.5</div></td>
</tr></table></div></address></body>
</html>
